﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace AnimalWars2
{
    public class StringUtils
    {
        private static float m_DefaultRotation = 0.0f;
        private static float m_DefaultLayerDepth = 0.5f;
        private static Vector2 m_DefaultOrigin = new Vector2(0f, 0f);
        private static Vector2 m_DefaultScale = new Vector2(1f, 1f);
        private static SpriteEffects m_DefaultSpriteEffects = SpriteEffects.None;
        private static Color m_DefaultFontColor = Color.White;
        private static Color m_DefaultFontBorderColor = Color.Black;

        // metodo completo, com suporte a sombra no texto
        public static Vector2 DrawString(SpriteFont spriteFont, SpriteBatch spriteBatch, String text, float x, float y, Color color, Color borderColor, float rotation, Vector2 origin, Vector2 scale, SpriteEffects spriteEffects, float layerDepth)
        {
            for (int fontX = -1; fontX <= 1 && borderColor != null; fontX++)
            {
                for (int fontY = -1; fontY <= 1; fontY++)
                {
                    spriteBatch.DrawString(spriteFont, text, new Vector2(x + fontX, y + fontY), borderColor, rotation, origin, scale, SpriteEffects.None, layerDepth + 0.1f);
                }
            }

            spriteBatch.DrawString(spriteFont, text, new Vector2(x, y), color, rotation, origin, scale, SpriteEffects.None, layerDepth);

            return spriteFont.MeasureString(text);
        }

        // metodo reduzido
        public static void DrawString(SpriteFont font, SpriteBatch spriteBatch, String str, int x, int y){
            DrawString(font, spriteBatch, str, x, y, m_DefaultFontColor, m_DefaultFontBorderColor, m_DefaultRotation, m_DefaultOrigin, m_DefaultScale, m_DefaultSpriteEffects, m_DefaultLayerDepth);
        }

        // metodo reduzido com possibilidade de customização de cor (texto e borda (sombra))
        public static Vector2 DrawString(SpriteFont spriteFont, SpriteBatch spriteBatch, String text, int x, int y, Color color, Color borderColor)
        {
            return DrawString(spriteFont, spriteBatch, text, x, y, color, borderColor, m_DefaultRotation, m_DefaultOrigin, m_DefaultScale, m_DefaultSpriteEffects, m_DefaultLayerDepth);
        }
    }
}
